<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!-- 准备好容器 -->
  <div id="test"></div>

  <!--引入react核心库-->
  <script src="../react.js-18/react.development.js" type="text/javascript"></script>
  <!--引入react-dom，用于支持react操作DOM-->
  <script src="../react.js-18/react-dom.development.js" type="text/javascript"></script>
  <!--引入label，用于将jsx转为js-->
  <script src="../react.js-18/babel.min.js" type="text/javascript"></script>
  <!--引入prop-types，用于对组件标签属性的限制-->
  <script src="../react.js-18/prop-types.js" type="text/javascript"></script>

  <script type="text/babel">
    //1.创建组件>
    class Time extends React.Component {
      state = { date: new Date() }

      componentDidMount() {
        setInterval(() => {
          this.setState({ date: new Date() })
        }, 1000)
      }

      render() {
        return (
          <div>
            <h1>hello</h1>
            <input type="text" />
            <span>现在是：{this.state.date.toTimeString()}</span>
          </div>
        )
      }
    }
    //2.渲染组件到页面
    ReactDOM.render(<Time />, document.getElementById('test'))
  </script>
</body>

</html>